package com.chainyoung.trademarket.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.bean.UserInfo;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.trademarket.entity.Ad;
import com.chainyoung.trademarket.mvp.contract.AdDetailContract;
import com.chainyoung.trademarket.mvp.contract.LoginContract;
import com.chainyoung.trademarket.mvp.model.AdDetailModel;

import java.util.TreeMap;

import javax.inject.Inject;



public class AdDetailPresenter extends BasePresenter<AdDetailContract.Model, AdDetailContract.View> {

    @Inject
    public AdDetailPresenter(AdDetailContract.Model model, AdDetailContract.View rootView) {
        super(model, rootView);
    }


    public void getAdDetail(TreeMap<String, Object> map) {

        addSubscribe(mModel.getAdDetail(map)
                .compose(RxUtils.<Ad>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<Ad>(mView) {
                    @Override
                    public void onNext(Ad data) {
                        mView.onGetAdDetail(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }


}
